package com.joysuch.wwyt.workflow.repository;

import com.joysuch.wwyt.workflow.entity.WorkFlowOption;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface WorkFlowOptionDao extends JpaRepository<WorkFlowOption, Long> {

    List<WorkFlowOption> findAllByOptionTypeOrderByShowOrder(Long optionTypeId);

    @Query("select t from WorkFlowOption t inner join  WorkFlowOptionType p  on t.optionType = p.id where p.optionType=:typeName and p.deleteFlag = '0' and t.deleteFlag = '0'order by t.showOrder ")
    List<WorkFlowOption> findAllByOptionTypeName(@Param("typeName") String typeName);

    int countByOptionTypeAndOptionName(Long optionType, String optionName);
}
